package com.sskj.lib.bean;

import com.sskj.common.base.App;
import com.sskj.lib.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 币币买入卖出
 */
public enum BuySellEnum {

    BUY("1", App.INSTANCE.getString(R.string.lib_buySellEnum1), R.color.libUpColor),

    SELL("2", App.INSTANCE.getString(R.string.lib_buySellEnum2), R.color.libDownColor);

    private String type;
    private String title;
    private int colorRes;
    private static List<BuySellEnum> list=new ArrayList<>();

    BuySellEnum(String type, String title, int colorRes) {
        this.type = type;
        this.title = title;
        this.colorRes = colorRes;
    }
    public List<BuySellEnum> list(){
        if (list.isEmpty()){
            list.addAll(Arrays.asList(BuySellEnum.values()));
        }
        return list;
    }
    public BuySellEnum getByType(String type){
        for (BuySellEnum buySellEnum : list()) {
            if (buySellEnum.getType().equals(type)){
                return buySellEnum;
            }
        }
        return BUY;
    }


    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        switch (this) {
            case SELL:
                return App.INSTANCE.getString(R.string.lib_buySellEnum2);
            case BUY:
                return App.INSTANCE.getString(R.string.lib_buySellEnum1);
            default:
                return App.INSTANCE.getString(R.string.lib_buySellEnum1);
        }

    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getColorRes() {
        return colorRes;
    }

    public void setColorRes(int colorRes) {
        this.colorRes = colorRes;
    }
}
